<template>
	<view class="container">
		<uni-easyinput v-model="data.telephone" placeholder="请输入手机号" />
		<uni-easyinput v-model="data.password" placeholder="请输入密码" type="password" />
		<button type="primary" @click="register">注册</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: {
					"telephone": "12345678913",
					"password": "123456"
				}
			}
		},
		methods: {
			register() {
				uni.request({
					url: 'http://localhost:8090/foodapp/user/register',
					method: 'post',
					data: this.data,
					success: res => {
						if (res.data.success) {
							uni.switchTab({
								url:"../my"
							})
							uni.showToast({
								title: '注册成功'
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		onLoad: () => {
			uni.onTabBarMidButtonTap(function(e){
				console.log(e)
			})
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
